<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /* 
    异步函数返回的是一个promise
     */

    async function foo() {
      // 1.返回普通的值
      // 相当于 Promise.resolve(123)
      // return 123

      //  2.返回一个promsie
      // return new Promise((resolve, reject) => {
      //   setTimeout(() => {
      //     resolve("aaa")
      //   }, 2000)
      // })

      // 3.返回一个thenable对象

      return {
        then: function (resolve, reject) {
          setTimeout(() => {
            resolve("bbb")
          }, 2000)

        }
      }
    }
    foo().then(res => {
      console.log(res);
    })
  </script>
</body>

</html>